<?php
include('include/config.inc.php');
if(!isset($_SESSION['s_activId'.$cfgPack])
  || (isset($_SESSION['s_userType'.$cfgPack]) && isset($cfgFileNames['party'][$_SESSION['s_userType'.$cfgPack]]) 
      && $cfgFileNames['party'][$_SESSION['s_userType'.$cfgPack]] == 0))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:checkLogin.php");
}
else
{
  $count = 0;
  $productArray = array();
	/////////////////  Filter date View:Start
	if(isset($_REQUEST['fromDateYear']))
		$fromDate  = $_REQUEST['fromDateYear']."-".$_REQUEST['fromDateMonth']."-".$_REQUEST['fromDateDay'];
	else
		$fromDate  = date("Y-m-01");
	
	if(isset($_REQUEST['toDateYear']))
		$toDate    = $_REQUEST['toDateYear']."-".$_REQUEST['toDateMonth']."-".$_REQUEST['toDateDay'];
	else
		$toDate    = date("Y-m-32");
	/////////////////  Filter date View:Stop
  
  $selectProduct = "SELECT proformamaster.proformaMasterId,proformamaster.date,party.companyName,deliverychallanmaster.srNo,proformamaster.totalAmt,proformamaster.notes
                      FROM proformamaster
                      JOIN deliverychallanmaster ON deliverychallanmaster.deliveryChallanMasterId = proformamaster.deliveryChallanMasterId
                      JOIN party ON party.partyId = deliverychallanmaster.partyId
                     WHERE date >= '".$fromDate."'
                       AND date <= '".$toDate."'
                       AND proformamaster.status = 'A'";                    
 
  $selectProductRes = mysql_query($selectProduct);
  while($row = mysql_fetch_array($selectProductRes))
  {
  	$productArray[$count]['proformaMasterId'] = $row['proformaMasterId'];
  	$productArray[$count]['date']         = $row['date'];
  	$productArray[$count]['companyName']  = $row['companyName'];
  	$productArray[$count]['srNo']         = $row['srNo'];
  	$productArray[$count]['totalAmt']     = $row['totalAmt'];
  	$productArray[$count]['notes']        = $row['notes'];
  	$count++;
  }
	
  include("./bottom.php");
  $smarty->assign("productArray",$productArray);
  $smarty->assign("fromDate",$fromDate);
  $smarty->assign("toDate",$toDate);
  $smarty->display("proformaList.tpl");
}
?>